package o;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Path.FillType;
import android.graphics.RadialGradient;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.Drawable;
import o.aqu.b;

public class asn extends aq {
    static final double ˎ = Math.cos(Math.toRadians(45.0d));
    float ʻ;
    private float ʻॱ;
    float ʼ;
    float ʽ;
    final Paint ˊ;
    private final int ˊॱ;
    final Paint ˋ;
    private boolean ˋॱ = true;
    final RectF ˏ;
    private boolean ˏॱ = true;
    private final int ͺ;
    float ॱ;
    private final int ॱˊ;
    private boolean ॱˎ = false;
    Path ॱॱ;
    float ᐝ;

    public asn(Context context, Drawable drawable, float f, float f2, float f3) {
        super(drawable);
        this.ˊॱ = fo.ˋ(context, b.ॱ);
        this.ॱˊ = fo.ˋ(context, b.ˏ);
        this.ͺ = fo.ˋ(context, b.ˋ);
        this.ˊ = new Paint(5);
        this.ˊ.setStyle(Style.FILL);
        this.ॱ = (float) Math.round(f);
        this.ˏ = new RectF();
        this.ˋ = new Paint(this.ˊ);
        this.ˋ.setAntiAlias(false);
        ˊ(f2, f3);
    }

    private static int ˎ(float f) {
        int round = Math.round(f);
        return round % 2 == 1 ? round - 1 : round;
    }

    public void ˋ(boolean z) {
        this.ˏॱ = z;
        invalidateSelf();
    }

    public void setAlpha(int i) {
        super.setAlpha(i);
        this.ˊ.setAlpha(i);
        this.ˋ.setAlpha(i);
    }

    protected void onBoundsChange(Rect rect) {
        this.ˋॱ = true;
    }

    public void ˊ(float f, float f2) {
        if (f < 0.0f || f2 < 0.0f) {
            throw new IllegalArgumentException("invalid shadow size");
        }
        float ˎ = (float) ˎ(f);
        float ˎ2 = (float) ˎ(f2);
        if (ˎ > ˎ2) {
            if (!this.ॱˎ) {
                this.ॱˎ = true;
            }
            ˎ = ˎ2;
        }
        if (this.ʼ != ˎ || this.ᐝ != ˎ2) {
            this.ʼ = ˎ;
            this.ᐝ = ˎ2;
            this.ʻ = (float) Math.round(ˎ * 1.5f);
            this.ʽ = ˎ2;
            this.ˋॱ = true;
            invalidateSelf();
        }
    }

    public void ॱ(float f) {
        ˊ(f, this.ᐝ);
    }

    public float ˏ() {
        return this.ʼ;
    }

    public boolean getPadding(Rect rect) {
        int ceil = (int) Math.ceil((double) ˏ(this.ᐝ, this.ॱ, this.ˏॱ));
        int ceil2 = (int) Math.ceil((double) ˊ(this.ᐝ, this.ॱ, this.ˏॱ));
        rect.set(ceil2, ceil, ceil2, ceil);
        return true;
    }

    public static float ˏ(float f, float f2, boolean z) {
        if (z) {
            return (float) (((double) (1.5f * f)) + ((1.0d - ˎ) * ((double) f2)));
        }
        return 1.5f * f;
    }

    public static float ˊ(float f, float f2, boolean z) {
        if (z) {
            return (float) (((double) f) + ((1.0d - ˎ) * ((double) f2)));
        }
        return f;
    }

    public int getOpacity() {
        return -3;
    }

    public void draw(Canvas canvas) {
        if (this.ˋॱ) {
            ॱ(getBounds());
            this.ˋॱ = false;
        }
        ˏ(canvas);
        super.draw(canvas);
    }

    public final void ˋ(float f) {
        if (this.ʻॱ != f) {
            this.ʻॱ = f;
            invalidateSelf();
        }
    }

    private void ˏ(Canvas canvas) {
        int save = canvas.save();
        canvas.rotate(this.ʻॱ, this.ˏ.centerX(), this.ˏ.centerY());
        float f = (-this.ॱ) - this.ʻ;
        float f2 = this.ॱ;
        Object obj = this.ˏ.width() - (2.0f * f2) > 0.0f ? 1 : null;
        Object obj2 = this.ˏ.height() - (2.0f * f2) > 0.0f ? 1 : null;
        float f3 = f2 / ((this.ʼ - (this.ʼ * 0.5f)) + f2);
        float f4 = f2 / ((this.ʼ - (this.ʼ * 0.25f)) + f2);
        float f5 = f2 / (f2 + (this.ʼ - (this.ʼ * 1.0f)));
        int save2 = canvas.save();
        canvas.translate(this.ˏ.left + f2, this.ˏ.top + f2);
        canvas.scale(f3, f4);
        canvas.drawPath(this.ॱॱ, this.ˊ);
        if (obj != null) {
            canvas.scale(1.0f / f3, 1.0f);
            canvas.drawRect(0.0f, f, this.ˏ.width() - (2.0f * f2), -this.ॱ, this.ˋ);
        }
        canvas.restoreToCount(save2);
        save2 = canvas.save();
        canvas.translate(this.ˏ.right - f2, this.ˏ.bottom - f2);
        canvas.scale(f3, f5);
        canvas.rotate(180.0f);
        canvas.drawPath(this.ॱॱ, this.ˊ);
        if (obj != null) {
            canvas.scale(1.0f / f3, 1.0f);
            canvas.drawRect(0.0f, f, this.ˏ.width() - (2.0f * f2), this.ʻ + (-this.ॱ), this.ˋ);
        }
        canvas.restoreToCount(save2);
        int save3 = canvas.save();
        canvas.translate(this.ˏ.left + f2, this.ˏ.bottom - f2);
        canvas.scale(f3, f5);
        canvas.rotate(270.0f);
        canvas.drawPath(this.ॱॱ, this.ˊ);
        if (obj2 != null) {
            canvas.scale(1.0f / f5, 1.0f);
            canvas.drawRect(0.0f, f, this.ˏ.height() - (2.0f * f2), -this.ॱ, this.ˋ);
        }
        canvas.restoreToCount(save3);
        save3 = canvas.save();
        canvas.translate(this.ˏ.right - f2, this.ˏ.top + f2);
        canvas.scale(f3, f4);
        canvas.rotate(90.0f);
        canvas.drawPath(this.ॱॱ, this.ˊ);
        if (obj2 != null) {
            canvas.scale(1.0f / f4, 1.0f);
            canvas.drawRect(0.0f, f, this.ˏ.height() - (2.0f * f2), -this.ॱ, this.ˋ);
        }
        canvas.restoreToCount(save3);
        canvas.restoreToCount(save);
    }

    private void ˎ() {
        RectF rectF = new RectF(-this.ॱ, -this.ॱ, this.ॱ, this.ॱ);
        RectF rectF2 = new RectF(rectF);
        rectF2.inset(-this.ʻ, -this.ʻ);
        if (this.ॱॱ == null) {
            this.ॱॱ = new Path();
        } else {
            this.ॱॱ.reset();
        }
        this.ॱॱ.setFillType(FillType.EVEN_ODD);
        this.ॱॱ.moveTo(-this.ॱ, 0.0f);
        this.ॱॱ.rLineTo(-this.ʻ, 0.0f);
        this.ॱॱ.arcTo(rectF2, 180.0f, 90.0f, false);
        this.ॱॱ.arcTo(rectF, 270.0f, -90.0f, false);
        this.ॱॱ.close();
        float f = -rectF2.top;
        if (f > 0.0f) {
            float f2 = this.ॱ / f;
            float f3 = f2 + ((1.0f - f2) / 2.0f);
            float[] fArr = new float[]{0.0f, f2, f3, 1.0f};
            f2 = 0.0f;
            this.ˊ.setShader(new RadialGradient(0.0f, f2, f, new int[]{0, this.ˊॱ, this.ॱˊ, this.ͺ}, fArr, TileMode.CLAMP));
        }
        f = 0.0f;
        this.ˋ.setShader(new LinearGradient(0.0f, rectF.top, f, rectF2.top, new int[]{this.ˊॱ, this.ॱˊ, this.ͺ}, new float[]{0.0f, 0.5f, 1.0f}, TileMode.CLAMP));
        this.ˋ.setAntiAlias(false);
    }

    private void ॱ(Rect rect) {
        float f = this.ᐝ * 1.5f;
        this.ˏ.set(((float) rect.left) + this.ᐝ, ((float) rect.top) + f, ((float) rect.right) - this.ᐝ, ((float) rect.bottom) - f);
        ˋ().setBounds((int) this.ˏ.left, (int) this.ˏ.top, (int) this.ˏ.right, (int) this.ˏ.bottom);
        ˎ();
    }
}
